Passed
Push — main ( 4fe5eb...9915cc )
by Andrii
02:23
created

expect-to-render.ts ➔ expectToRender   A

Complexity

Conditions 2

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 11
c 0
b 0
f 0
rs 9.95
cc 2
1
import {renderToStaticMarkup} from "react-dom/server"
2
3
const {isArray: $isArray} = Array
4
5
export default expectToRender
6
7
function expectToRender(
8
  element: Parameters<typeof renderToStaticMarkup>[0],
9
  expectation: string | string[] 
10
) {
11
  return expect(
12
    renderToStaticMarkup(element)
13
  ).toBe(
14
    !$isArray(expectation)
15
    ? expectation
16
    : expectation.join("")
17
  )
18
}
19